package thread;

/**
 * @author tongchen
 * @create 2023-01-04 18:09
 */
public class exer2 {
    static boolean  isQuit=true;
    public static void main(String[] args) throws InterruptedException {

        Thread thread=new Thread(()->{
            while(isQuit){
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //线程执行前的状态和存活
        System.out.println(thread.getState());
        System.out.println(thread.isAlive());
        //线程执行
        thread.start();
        System.out.println("zhong"+thread.getState());
        System.out.println("zhong"+thread.isAlive());
        isQuit=false;
        //线程执行后
        Thread.sleep(1000);
        System.out.println("后"+thread.getState());
        System.out.println("后"+thread.isAlive());

    }
}
